# 元组和集合
# 元组的创建
tuple_01 = ('a','b',1,2,3)
tuple_02 = 'a','b',1,2,3
# print(tuple_02)
# print(tuple_01)
tuple_03 = ()
list_01 = [1]
tuple_04 = (1,)  # 元组
item_01 = (1)  # 不是元组
# print(list_01)
# print(tuple_03)
# print(tuple_04)
# print(item_01)

# 序列转换成元组:tuple()函数
list_02 = ['a','bb','ccc',123,456,789,['abc','def']]
tuple_05 = tuple(list_02)
# print(list_02)
# print(tuple_05)

# 访问元组
# print(tuple_05[6])

# 元组的合并：+
tuple_06 = tuple_05 + tuple_02
# print(tuple_05)
# print(tuple_02)
# print(tuple_06)

# 元组的遍历
# for i in tuple_06:
#     print(i)

# print(len(tuple_06))
# j = 0
# while j < len(tuple_06):
#     print(tuple_06[j])
#     j += 1


# 集合
set_01 = {'a','b','c',1,2,3}
# set_04 = {'a','b',[1,2,3],1}  # 集合里面的元素不可以包含列表
# print(set_04)
set_02 = set(list_01)
set_03 = set(tuple_02)
# print(set_01)
# print(set_02)
# print(set_03)
# print(set_01)
set_01.add('aaa')
# print(set_01)
# set_01.update(set_02)
# print(set_02)
# print(set_01)
# set_01.update(set_03)
# print(set_03)
# print(set_01)
# item_02 = set_01.pop()
# print(item_02)
# print(set_01)
# # set_04 = {}
# # item_03 = set_04.pop()  # set_04为空集合，会抛出异常（报错）
# # print(item_03)
# # print(set_04)
# set_01.remove('a')
# # set_01.remove('bbb')  # set_01不存在'bbb'元素，会报错
# print(set_01)
# set_01.discard('b')
# set_01.discard('bbb')  # set_01不存在'bbb'元素，但不会报错
# print(set_01)
# set_01.clear()
# print(set_01)

#  集合的运算
set_04 = {1,2,3,4,5,6}
set_05 = {1,2,3,7,8,9}
print(set_04 & set_05)
print(set_04 | set_05)
print(set_04 - set_05)
print(set_04 ^ set_05)

set_06 = {1,2,4}
print(set_06 <= set_04)
print(set_06 <= set_05)
print(set_04 <= set_04)

set_07 = {1,2,4,7,8}
print(set_07 >= set_06)
print(set_07 >= set_05)
print(set_07 >= set_07)